﻿using System;
using System.Collections.Generic;
/// <summary>
/// 卡牌技能基类
/// </summary>
[Serializable]
public class SkillBase
{
    public string className = "";
    public List<PropertyValue<PropertyBase>> propertyList = new List<PropertyValue<PropertyBase>>();

    public SkillBase(){
        //ClassName = this.GetType().FullName;
        className = this.GetType().FullName;
    }
    /// <summary>
    /// 重新创建单个大项内的属性
    /// </summary>
    /// <param name="propertyListVal"></param>
    public virtual void InitData(List<PropertyValue<PropertyBase>> propertyListVal){
        int index = 0;
        //重新创建后本身的属性列表
        foreach(var _item in propertyList){
            //从json转回来的属性列表
            foreach(var item in propertyListVal){
                if(_item.discript == item.discript){
                    // if(index == 0) item.val.className = "Ordinary";
                    // if(index == 1) item.val.className = "Resistance";
                    // if(index == 2) item.val.className = "ElementalInjury";
                    var assembly = Utils.GetCurAssembly();
                    _item.val = (PropertyBase)assembly.CreateInstance(item.val.className); 
                    //通过类型创建
                    // var _classType = Type.GetType(item.val.className+",");
                    // _item.val = (PropertyBase)Activator.CreateInstance();
                    _item.val.InitData(item.val.propertyList);
                    index++;
                }
            }
        }
    }
}

